﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GLImp;

namespace BoneImp {
	class TextureAttachmentLoader : AttachmentLoader {
		List<Region> Regions = new List<Region>();
		public string Directory = "";

		public TextureAttachmentLoader(string Directory) {
			this.Directory = Directory;
		}

		public override Region findRegion(string RegionName) {
			Region ret = GetRegion(RegionName);
			if(ret == null) {
				ret = new Region();
				ret.texture = new Texture(Directory + RegionName + ".png");
				ret.x = 0;
				ret.y = 0;
				ret.width = ret.texture.Width;
				ret.height = ret.texture.Height;
				ret.name = RegionName;
				ret.rotate = false;
				Regions.Add(ret);
			}
			return ret;
		}

		private Region GetRegion(string RegionName) {
			foreach (Region r in Regions){
				if (r.name == RegionName){
					return r;
				}
			}
			return null;
		}
	}
}
